<%--
    Document   : listRecentComments
    Created on : Apr 27, 2014, 4:47:58 PM
    Author     : Anton Strack
--%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="csd" tagdir="/WEB-INF/tags" %>
<%@tag description="Lists the recent posts passed on the recentPosts attribute " pageEncoding="UTF-8"%>
<%@attribute name="recentComments" type="java.util.List<csdwa.Comment>"%>
<%@attribute name="emptyMessage" required="true"%>
<c:choose>
    <c:when test="${recentComments != null && recentComments.size() > 0}">

        <c:forEach items="${recentComments}" var="recentComment" >
            <li class="list-group-item"><a href="${req.contextPath}?action=view&resource=${fn:toLowerCase(recentComment.getDerivedValue('ParentResourceTypeName'))}&id=${recentComment.parentId}">${recentComment.name}</a><br />
                <c:choose>
                    <c:when test="${recentComment.updatedDate > recentComment.createdDate}">
                        Updated: <csd:displayTimestamp timestamp="${recentComment.updatedDate}"></csd:displayTimestamp>
                    </c:when>
                    <c:otherwise>
                        Created: <csd:displayTimestamp timestamp="${recentComment.updatedDate}"></csd:displayTimestamp>
                    </c:otherwise>
                </c:choose>
                &nbsp;By: ${recentComment.getDerivedValue("UpdatedByName")}
            </li>
        </c:forEach>
    </c:when>
    <c:otherwise>
        <li class="list-group-item">${emptyMessage}</li>
        </c:otherwise>
    </c:choose>

